package com.mallotec.android.timenote.data.bean.comparator;

import com.mallotec.android.timenote.data.bean.Timenote;

/**
 * @author reborn
 * @program TimeNote
 * @description
 * @create 2020-11-14 09:31
 **/
public class TimenoteComparator implements java.util.Comparator<Timenote> {
    @Override
    public int compare(Timenote timenote, Timenote t1) {
        if (timenote.getEndDatetime() == null && t1.getEndDatetime() == null)
            return timenote.getStartDatetime().getTimeInMillis() > t1.getStartDatetime().getTimeInMillis()
                    ? -1 : 1;
        else if (timenote.getEndDatetime() == null)
            return -1;
        else if (t1.getEndDatetime() == null)
            return 1;
        else if (timenote.getEndDatetime() != null)
            return 1;
        else if (t1.getEndDatetime() != null)
            return -1;
        else
            return 0;
    }
}
